<?php
/**
 * Description of event
 *
 * @author 雅典娜之子
 */

!defined('ACCESSING') && die('Hacking attempt');

require_once $BASE['corepath'].'base.class.php';
require_once $BASE['corepath'].'archives.class.php';
require_once $BASE['corepath'].'images.class.php';
require_once $BASE['corepath'].'page.class.php';

class GlobalEvent extends Base {
    var $view;
    var $action;
    var $temppath;
    public function  __construct()
    {
        parent::__construct();
        $this->action = parent::GetStr('action');
		$this->view = parent::GetStr('view');
		$this->temppath = $this->base['temppath'];

        if(empty($this->view) && empty($this->action))
		{
			$this->view = 'homepage';
		}

        $this->justdo();
    }

    public function GlobalEvent()
    {
        $this->__construct();
    }

    function justdo()
    {
        if( !empty ($this->action) )
        {
            switch ($this->action)
            {
                case 'ajax_getfxlist':
                    if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
                    {
                        $aid = parent::GetStr('id');
                        $this->ajax_getfxintro($aid);
                    }
                    break;
            }
        }

        if( !empty ($this->view) )
        {
            switch ($this->view)
            {
                case 'homepage':
                    $this->homepage();
                    break;
                case 'fx-list':
                    $this->fx_list();
                    break;
            }
        }
    }

    public function homepage()
    {
        $archives = new Archives();
        $newslist = $archives->NewsList(12,null,4);
        $fx = $archives->getfxlist(2,true,true);
        parent::display($this->temppath.'index',array($newslist,$fx));
    }

    public function fx_list()
    {
        $archives = new Archives();
        $fxlist = $archives->getfxlist2();
        parent::display($this->temppath.'fxlist',array($fxlist));
    }

    public function ajax_getfxintro($aid)
    {
        $archives = new Archives();
        $fxintro = $archives->GetArcInfo($aid);
        $intro = $fxintro['intro'];
        if(!empty($intro) || $intro != "")
        {
            echo $intro;
        }
        else
        {
            echo "Nothing!!";
        }
    }
}
?>
